package com.ark.common.exception;

import com.ark.common.constant.Constants;
import com.ark.common.response.Result;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;


@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class ServiceException extends RuntimeException{

    private Integer code;
    private String message;
    private String detailMessage;

    public ServiceException(Result result) {
        this.code = (Integer) result.get(Constants.CODE_TAG);
        this.message = (String) result.get(Constants.MSG_TAG);
    }

    public ServiceException(String message) {
        this.message = message;
    }

    public ServiceException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public ServiceException setDetailMessage(String detailMessage)
    {
        this.detailMessage = detailMessage;
        return this;
    }


    @Override
    public String getMessage()
    {
        return message;
    }
}
